﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
using MySql.Data.Types;
using TAMS;

namespace TAMS.Instructor
{
    public partial class Ins_Courses : System.Web.UI.Page
    {
        MySqlConnection conn;
        MySqlCommand sqlCommand;
        MySqlDataReader readVals;
        string strProvider = Resource1.databaseConnection;
        string id;

        protected void Page_Load(object sender, EventArgs e)
        {
            ((Menu)Master.FindControl("Menu1")).Items[0].Selected = true;
            // Connect to the Database
            conn = new MySqlConnection(strProvider);
            conn.Open();

            // Get the id from querystring
            id = (string)Session["userName"];

            if (id == null)
                Response.Redirect("../login.aspx");

            string strSQL = " SELECT C.cid AS \"CourseID\", C.cname AS \"Course Name\", SC.sectionNo AS \"Section\", SM.season AS \"Season\", SM.Year " +
                            " FROM Educates E, Course C, SectionConsists SC, Semester SM " +
                            " WHERE C.cid = SC.cid AND E.fsid = " + id + " AND SC.secCorsId = E.secCorsId AND SM.semId = SC.semId";

            sqlCommand = new MySqlCommand(strSQL, conn);
            readVals = sqlCommand.ExecuteReader();

            MainTable.DataSource = readVals;
            MainTable.DataBind();
            conn.Close();
        }

        protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {

        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void details_clicked(object sender, EventArgs e)
        {

        }

        protected void select_clicked(object sender, EventArgs e)
        {

        }
    }
}